package com.alingrad.android.froyoengine.test.multitouch;

import javax.microedition.khronos.opengles.GL10;

import com.alingrad.android.froyoengine.Game;
import com.alingrad.android.froyoengine.graphics.renderable.Square;
import com.alingrad.android.froyoengine.input.TouchState;
import com.alingrad.android.froyoengine.tree.MainLoop;
import com.alingrad.android.froyoengine.util.GLColor;

public class MultiTouchTestMainLoop extends MainLoop {

	private Square[] mSquares;
	
	@Override
	public void update(long delta) {
		for (int i = 0; i < 4; i++) {
			TouchState state = Game.sInputManager.getTouchState(i);
			if (state.isActive())
				Game.sRenderManager.scheduleToRender(mSquares[i], state.mX, state.mY, -5f, 0f);
		}
	}

	@Override
	public void load(GL10 gl) {
		mSquares = new Square[4];
		mSquares[0] = new Square(128);
		mSquares[0].setColor(GLColor.RED);
		mSquares[1] = new Square(128);
		mSquares[1].setColor(GLColor.GREEN);
		mSquares[2] = new Square(128);
		mSquares[2].setColor(GLColor.BLUE);
		mSquares[3] = new Square(128);
		mSquares[3].setColor(GLColor.CYAN);
	}

	@Override
	public boolean isAlive() {
		return true;
	}

}
